{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ransacMatching(A, B, k, d):\n",
    "    \"\"\"\n",
    "    Input:\n",
    "        A,B - two pairs of points\n",
    "         k  - the max value of iterations\n",
    "         d  - at least d pairs of points fit for  homography\n",
    "    Output:\n",
    "        besthomography\n",
    "        \n",
    "    iterations = 0\n",
    "    besthomography = None\n",
    "    while(iterations < k ):\n",
    "        pick_n_pairs_points = pick up N pairs of points from A and B\n",
    "        maybe_homography = choose 4 pairs of points from pick_n_pairs_points to work out a homography\n",
    "        fit_homography_points = init emptyset\n",
    "        for(i in pick_n_pairs_points except 4 pairs of points):\n",
    "            if(i fit for maybe_homography):\n",
    "                fit_homography_points.append(i)\n",
    "        if(len(fit_homography_points) >= d):\n",
    "            besthomography = maybe_homography\n",
    "        iterations++\n",
    "    return besthomography\n",
    "    \n",
    "    \"\"\"\n",
    "            "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
